package com.xyy.saas.payment.adpater.abchinaLoan.config;

import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author wangzeqi
 */
@Data
@Configuration
@ConfigurationProperties("abchina.loan")
public class AbchinaLoanConfig {

    private String pfxFileName = "abchina-dev.pfx";
    private String cerFileName = "abchina-dev.cer";

    private String appId = "b6e9e2c7-3aba-40c5-81ed-20913c1f0352";
    private String appSecret = "cff054d1d7c84036a3dc160f9457e5f423704b15";

    /**
     * 合作方自己的证书密码
     */
    private String pfxPwd = "111111";

    private Client client = new Client();
    private RequestUrl requestUrl = new RequestUrl();

    @Getter
    @Setter
    @ToString
    public static class Client {
        private int timeout = 15 * 1000;
    }

    @Getter
    @Setter
    @ToString
    public static class RequestUrl {

        /**
         * 贷款申请单H5
         */
        private String applyH5 = "https://obgateway.test.abchina.com/AraratGateWay/openabc/h5/chainELoan/homePage/v1";

        /**
         * 贷款申请状态查询
         */
        private String queryLoanStatus = "https://obgateway.test.abchina.com/AraratGateWay/openabc/api/chainELoan/queryApplyState/v1";

        /**
         * 订单支付资质核验
         */
        private String orderCheck = "https://obgateway.test.abchina.com/AraratGateWay/openabc/api/chainELoan/verifyElements/v1";

        /**
         * 订单变动确认及通知
         */
        private String orderChangeNotify = "https://obgateway.test.abchina.com/AraratGateWay/openabc/api/chainELoan/orderNotification/v1";

    }

    @ApolloConfigChangeListener
    private void someOnChange(ConfigChangeEvent changeEvent) {
        // update injected value of batch if it is changed in Apollo
        /*if (changeEvent.isChanged("batch")) {
            batch = config.getIntProperty("batch", 100);
        }*/
    }

}
